package sasp_protocol;
//Entity is the location for all information about each node in the protocol
// to exsist. Each time a new user joins the session a new entity object
// is created to house data specific to this user.

import org.boehn.kmlframework.kml.Document;
import org.boehn.kmlframework.kml.Kml;
import org.boehn.kmlframework.kml.KmlException;
import org.boehn.kmlframework.kml.Placemark;


public class Entity {
protected String Alias = "Unknown User";
protected String IP = "127.0.0.1";
protected int PORT = 12345;
private int EntityID = 0;
private int messCount = 0;
private String Image = "Default"; // Need to update with actual image code
protected double longitude = (float) -75.166397;
protected double latitude = (float) 39.954096;
private int altitude = 0;
public Placemark mark = new Placemark(Alias);

// This go method is used to tell the entity to write it's cordinates to the
// placemark object. This placemark object is what is read by KMLgen to
// put the coordinates and alias on the map

public void go(){
mark.setLocation(longitude, latitude);
mark.setName(Alias);
try{
	Thread.sleep(1000);
}catch(InterruptedException ex){
	ex.printStackTrace();
}
}

	
// Method used in prtocol to set the IP address of a certian entity

public void setIpString( String _ipString ) {
    String [] addr = _ipString.split(":");
    this.IP = addr[0];
    this.PORT = Integer.parseInt(addr[1]);
}

public String getIpString( ) {
    String retVal = this.IP + ":" + Integer.toString(this.PORT);
    return retVal;
}

public int getMessageCount( ) {
    return messCount++;
}

public boolean checkMessageCount( int _m ) {
    if( _m >= messCount ) {
        return true;
    } else {
        return false;
    }
}

public void setMessageCount( int _m ) {
    messCount = _m;
}

public void SetAlias(String name){
	Alias = name;
}
public void SetEntityID(int ID){
	EntityID = ID;
}
public void SetImage(String Pic){
	Image = Pic;	
}
public void Setlongitude (double longi){
	longitude = longi;
}
public void Setlatitude (double lat){
	latitude = lat;
}
public void Setaltitude (int alt){
	altitude = alt;
}
public String GetAlias(){
	return Alias;
}
public String GetListAlias(){
	return Alias + ":" + this.getIpString() + ":" + this.GetEntityID();
}
public int GetEntityID(){
	return EntityID;
}
public String Getimage(){
	return Image;
}
public Double Getlongitude(){
	return longitude;
}
public Double Getlatitutde(){
	return latitude;
}
public int Getaltitude(){
	return altitude;
}
}



